package com.tpc.dao.core;

import java.util.Date;

/**
 * @version 0.0.1
 * @author frederic.fortin
 * @modified 2010-09-02
 */
import com.google.gwt.user.client.rpc.IsSerializable;

public class User implements IsSerializable {

    private int id;
    private String FirstName;
    private String LastName;
    private String username;
    private String password;
    private String SexChar;
    private Date Birthdate;
    private String BirthdateString;
    private String Description;
    private Tag title;
    private Tag function;
    private String createdDateString;
    private String modifiedDateString;
    private int created_by;
    private int modified_by;
    private Date created_date;
    private Date modified_date;
    private int life;
    private Address address;
    private Address[] Addresses;
    private com.tpc.dao.extend.Organisation compagnie;
    private Url email;
    private Url email2;
    private Url[] Emails;
    private Phone phoneBusiness;
    private Phone phoneHome;
    private Phone phoneMobile;
    private Phone[] Phones;
    private com.tpc.dao.extend.Language Langue;
    private int GroupeDefaut;
    private String isAdmin;
    private int[] GroupesListe;
    private String loginPath;

    public User() {

    }

    public User(int idParam, String strFirstNameParam, String strLastNameParam) {
        id = idParam;
        FirstName = strFirstNameParam;
        LastName = strLastNameParam;
    }

    public void setAddressHome(int param0,String param,String param1,int param2) {
        address = new Address();
        address.setId(param0);
        address.setStreet(param);
        address.setSuite(param1);
        address.setZipcodeId(param2);
    }
    public void setAddressHome(int param0,String param,String param1,int param2,String param3,String param4,String param5) {
        address = new Address();
        address.setId(param0);
        address.setStreet(param);
        address.setSuite(param1);
        address.setZipcodeId(param2);
        address.setZipcode(param3);
        address.setCityName(param4);
        address.setCountryName(param5);
    }
    public void setAddressHome(int addressID,String addressStreet,String addressSuite,int zipcodeID,String zipcodeCODE,int cityID,String cityNAME,int StateID,String stateNAME,int countryID,String countryNAME) {
        address = new Address();
        address.setId(addressID);
        address.setStreet(addressStreet);
        address.setSuite(addressSuite);
        address.setZipcodeId(zipcodeID);
        address.setZipcode(zipcodeCODE);
        address.setCityId(cityID);
        address.setCityName(cityNAME);
        address.setStateId(StateID);
        address.setStateName(stateNAME);
        address.setCountryId(countryID);
        address.setCountryName(countryNAME);
    }
    public Address getAddressHome() {
        return address;
    }

    public int getId() {
        return id;
    }
    public void setId(int idP) {
        id = idP;
    }

    public void setUsername(String param) {
        username = param;
    }
    public String getUsername() {
        return username;
    }

    public String[] getGroups() {

        return null;
    }

    public void setLoginPath(String param) {
        loginPath = param;
    }
    public String getLoginPath() {
        return loginPath;
    }

    public void setGroupeDefaut(int param) {
        GroupeDefaut = param;
    }
    public int getGroupeDefaut() {
        return GroupeDefaut;
    }

    public void setIsAdmin(String param) {
        isAdmin = param;
    }
    public String getIsAdmin() {
        return isAdmin;
    }

    public void setPassword(String param) {
        password = param;
    }
    public String getPassword() {
        return password;
    }

    public String getFirstName() {
        return FirstName;
    }

    public String getLastName() {
        return LastName;
    }

    public String getFullName() {
        String Name = "";
        if (FirstName != null) {
            Name = FirstName;
        }
        if (LastName != null) {
            if (Name.length() > 0) {
                Name = Name+" ";
            }
            Name += LastName;
        }
        return Name;
    }

    public String getSexChar() {
        return SexChar;
    }

    public com.tpc.dao.extend.Language getLangue() {
        return Langue;
    }
    public void setLangue(int param) {
        Langue = new com.tpc.dao.extend.Language();
        Langue.setId(param);
    }
    public void setLangue(int idparam,String param) {
        Langue = new com.tpc.dao.extend.Language();
        Langue.setId(idparam);
        Langue.setName(param);
    }

    public Tag getTitle() {
        return title;
    }
    public void setTitle(String strP) {
        title = new Tag();
        title.setName(strP);
    }
    public void setTitle(int param) {
        title = new Tag();
        title.setId(param);
    }
    public void setTitle(int param,String param2) {
        title = new Tag();
        title.setId(param);
        title.setName(param2);
    }

    public Tag getFunction() {
        return function;
    }
    public void setFunction(String strP) {
        function = new Tag();
        function.setName(strP);
    }
    public void setFunction(int param) {
        function = new Tag();
        function.setId(param);
    }
    public void setFunction(int param,String strP) {
        function = new Tag();
        function.setId(param);
        function.setName(strP);
    }

    public Date getBirthDate() {
        return Birthdate;
    }

    public String getDescription() {
        return Description;
    }

    public void setEmails(Url[] param) {
        Emails = param;
    }
    public Url getEmail() {
        if (email == null) {
            if (Emails != null) {
                for (int i = 0; i < Emails.length; i++) {
                    if (Emails[i].getDefaut() == 1) {
                        email = Emails[i];
                    }
                }
            }
        }
        return email;
    }
    public Url getEmail2() {
        if (email2 == null) {
            if (Emails != null) {
                for (int i = 0; i < Emails.length; i++) {
                    if (Emails[i].getDefaut() != 1) {
                        email2 = Emails[i];
                    }
                }
            }
        }
        return email2;
    }
    public void setEmail(int idp,String param) {
        email = new Url();
        email.setId(idp);
        email.setUrl(param);
    }
    public void setEmail2(int idp,String param) {
        email2 = new Url();
        email2.setId(idp);
        email2.setUrl(param);
    }

    public Phone getPhones(String TYPE) {
        Phone phone = null;
        if (Phones != null) {
            for (int i = 0; i < Phones.length; i++) {
                if (Phones[i].getType().equals(TYPE)) {
                    phone = Phones[i];
                    break;
                }
            }
        }
        return phone;
    }
    public void setPhones(Phone[] param) {
        Phones = param;
    }

    public Phone getPhoneBusiness() {
        return phoneBusiness;
    }
    public void setPhoneBusiness(int idp,String areacodep,String numberp,String extensionp) {
        phoneBusiness = new Phone();
        phoneBusiness.setId(idp);
        if (areacodep == null) {
            areacodep = "";
        }
        phoneBusiness.setAreacode(areacodep);
        if (numberp == null) {
            numberp = "";
        }
        phoneBusiness.setNumber(numberp);
        if (extensionp == null) {
            extensionp = "";
        }
        phoneBusiness.setExtension(extensionp);
    }

    public Phone getPhoneMobile() {
        return phoneMobile;
    }
    public void setPhoneMobile(int idp,String areacodep,String numberp) {
        phoneMobile = new Phone();
        phoneMobile.setId(idp);
        if (areacodep == null) {
            areacodep = "";
        }
        phoneMobile.setAreacode(areacodep);
        if (numberp == null) {
            numberp = "";
        }
        phoneMobile.setNumber(numberp);
    }

    public Phone getPhoneHome() {
        return phoneHome;
    }
    public void setPhoneHome(int idp,String areacodep,String numberp) {
        phoneHome = new Phone();
        phoneHome.setId(idp);
        if (areacodep == null) {
            areacodep = "";
        }
        phoneHome.setAreacode(areacodep);
        if (numberp == null) {
            numberp = "";
        }
        phoneHome.setNumber(numberp);
    }

    public com.tpc.dao.extend.Organisation getOrganisation() {
        return compagnie;
    }
    public void setOrganisation(int param) {
        compagnie = new com.tpc.dao.extend.Organisation();
        compagnie.setId(param);
    }
    public void setOrganisation(int param,String param2) {
        compagnie = new com.tpc.dao.extend.Organisation();
        compagnie.setId(param);
        compagnie.setName(param2);
    }
    public void setOrganisation(String param,String param1,String param2) {
        compagnie = new com.tpc.dao.extend.Organisation();
        compagnie.setName(param);
        compagnie.setAddress(-1,null,null,null,param1,param2);
    }

    public void setOrganisation(int idparam,String param,String param2,String param3,String param5,String param6,String param7) {
        compagnie = new com.tpc.dao.extend.Organisation();
        compagnie.setAddress(id,param,param2,param3,param5,param6,param7);
    }

    public void setOrganisation(int idparam,String param,String param2,String param3,String param4,String param5,String param6,String param7) {
        compagnie = new com.tpc.dao.extend.Organisation();
        compagnie.setId(idparam);
        compagnie.setName(param);
        compagnie.setAddress(-1,param2,param3,param4,param5,param6,param7);
    }

    public void setFirstName(String strP) {
        FirstName = strP;
    }

    public void setLastName(String strP) {
        LastName = strP;
    }

    public void setSexChar(String strP) {
        SexChar = strP;
    }

    public void setBirthDate(Date dateP) {
        Birthdate = dateP;
    }
    public void setBirthDateAsString(String param) {
        if (param != null) {
            if (param.length() > 5) {
                String strDay =param.substring(0,1);
                String strMonth = param.substring(3,4);
                String strYear = param.substring(6,9);
                BirthdateString = strYear+"-"+strMonth+"-"+strDay+" 00:00:00";
            }
        }
    }
    public String getBirthDateAsString() {
        return "";
    }

    public void setDescription(String strP) {
        if (strP == null) {
            strP = "";
        }
        Description = strP;
    }

    public String getCreatedDateAsString() {
        return "créé le "+createdDateString;
    }
    public void setCreatedDateAsString(String param) {
        createdDateString = param;
    }

    public String getModifiedDateAsString() {
        return "modifié le "+modifiedDateString;
    }
    public void setModifiedDateAsString(String param) {
        modifiedDateString = param;
    }

}